<!--
 * Copyright (c) 2009 The Chromium Authors. All rights reserved.  Use of this
 * source code is governed by a BSD-style license that can be found in the
 * LICENSE file.
-->
<html>
<head>
<script>
  var objRegExp = /http:\/\/www\.youtube\.com.*v=([^&]*).*/;
	
  chrome.pageAction.onClicked.addListener(function(tab) {
	var action_url = "http://www.dirpy.com/";
	var vid_id = tab.url.replace(objRegExp, "$1");
	if(vid_id != tab.url) {
		action_url += "studio/" + vid_id;
	}
	chrome.tabs.create({ url: action_url });
  });
  
  function checkForValidUrl(tabId, changeInfo, tab) {
	if (objRegExp.test(tab.url)) {
	  chrome.pageAction.show(tabId);
	}
  };

  // Listen for any changes to the URL of any tab.
  chrome.tabs.onUpdated.addListener(checkForValidUrl);
</script>
</head>
</html>
